package com.medata.utils;

import com.medata.dataObject.Account;
import com.medata.service.AccountService;
import org.apache.shiro.SecurityUtils;

/**
 * @author ：zb
 * @date ：Created in 2019/5/22 0022 8:49
 * @description：
 */

public class AuthorityUtil {
    public static Integer hasAuthority(AccountService accountService,String dbid){
        String name =(String)SecurityUtils.getSubject().getPrincipal();
        Account account = accountService.findByUserName(name);
        String dbids = account.getDbids();
        int has=0;
        if (dbids!=null&&!dbids.isEmpty()){
            String[] ids = dbids.split(",");
            for (String i:ids){
                if (i.equals(dbid)){
                    has=1;
                }
            }
        }
        return has;
    }

}
